package furns.entity;

import javax.swing.*;
import java.util.List;

//Page是一个Javabean 是一个分页的数据模型(包含了分页的各种信息)
//T表示泛型，因为将来分页模型对应的数据类型是不确定的
public class Page<T> {
    public static final Integer PAGE_SIZE = 3;
    private Integer pageNo;     //表示显示当前页[显示第几页] -->前端
    private Integer pageSize = PAGE_SIZE;  //一页有多少记录 -->前端给出数据
    private Integer pageTotalCount; //总共有多少页-->计算
    private Integer totalRow;  //总共的记录  -->可以从数据库查出来，在DAO层写
    private List<T> items;      //每页的数据 -->可以从数据库查出来，在DAO层写·
    private String url;        //分页导航的字符串

    public Page() {
    }

    public Page(Integer pageNo, Integer pageSize, Integer pageTotalCount, Integer totalRow, List<T> items, String url) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.pageTotalCount = pageTotalCount;
        this.totalRow = totalRow;
        this.items = items;
        this.url = url;
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getPageTotalCount() {
        return pageTotalCount;
    }

    public void setPageTotalCount(Integer pageTotalCount) {
        this.pageTotalCount = pageTotalCount;
    }

    public Integer getTotalRow() {
        return totalRow;
    }

    public void setTotalRow(Integer totalRow) {
        this.totalRow = totalRow;
    }

    public List<T> getItems() {
        return items;
    }

    public void setItems(List<T> items) {
        this.items = items;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public String toString() {
        return "Page{" +
                "pageNo=" + pageNo +
                ", pageSize=" + pageSize +
                ", pageTotalCount=" + pageTotalCount +
                ", totalRow=" + totalRow +
                ", items=" + items +
                ", url='" + url + '\'' +
                '}';
    }
}
